//
// Created by LiuYou on 2021/10/28.
//

#include <iostream>
#include <cstring>


static void* startRoutine(void* args) {

    fputs( "线程正在工作！", stdout );

    return nullptr;
}


int main(int argc, char** argv) {

    fputs( "开始！", stdout );

    pthread_t tid{};
    int ret = pthread_create( &tid, nullptr, startRoutine, nullptr );
    if (ret != 0) {
        // 注意: pthread_create();失败了, 不能使用 perror();进行报错了。
        fprintf( stderr, "pthread_create(): %s.\n", strerror(errno));
        return 1;
    }

    fputs( "结束！", stdout );


    return 0;
}
// 运行结果:
/*
liuyou@liuyou-virtual-machine:~/CLionProjects/LinuxEnvironmentProgramming2/src/concurrence/parallel/thread$ ./create1
开始！结束！线程正在工作！liuyou@liuyou-virtual-machine:~/CLionProjects/LinuxEnvironmentProgramming2/src/concurrence/parallel/thread$ ./create1
开始！结束！liuyou@liuyou-virtual-machine:~/CLionProjects/LinuxEnvironmentProgramming2/src/concurrence/parallel/thread$ ./create1
开始！结束！liuyou@liuyou-virtual-machine:~/CLionProjects/LinuxEnvironmentProgramming2/src/concurrence/parallel/thread$ ./create1
开始！结束！liuyou@liuyou-virtual-machine:~/CLionProjects/LinuxEnvironmentProgramming2/src/concurrence/parallel/thread$ ./create1

线程的调度取决于CPU的调度策略。
 */
